package cn.lx.auth.secutity.mock;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

/**
 * @ClassName MockSecurityConfig
 * @Description: //todo
 * @Author: 落雪
 * @CreateDate: 2025/7/14 23:23
 * @UpdateUser: 落雪
 * @UpdateDate: 2025/7/14 23:23
 * @UpdateRemark:
 * @Version: 1.0
 */
@ConditionalOnProperty(
        name = {"security.type"},
        havingValue = "hsa-mock"
)
public class MockSecurityConfig extends WebSecurityConfigurerAdapter {
    @Value("${security.oauth2.client.permits:'/hsaf_pass'}")
    private String permits;

    public MockSecurityConfig() {
    }
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        ((HttpSecurity)((HttpSecurity)((HttpSecurity)((ExpressionUrlAuthorizationConfigurer.AuthorizedUrl)((ExpressionUrlAuthorizationConfigurer.AuthorizedUrl)http.authorizeRequests().antMatchers(new String[]{"/**"})).permitAll().anyRequest()).authenticated().and()).headers().frameOptions().disable().and()).logout().and()).addFilterAfter(new MockUserContextFilter(), UsernamePasswordAuthenticationFilter.class).csrf().disable();
    }
}

